package xcode

import (
	"beyond_go-zero/pkg/xcode/types"
	"fmt"
	"net/http"
)

func ErrHandler(err error) (int, any) {
	fmt.Println("========= err", err)

	//errToStr := err.Error()
	//message := ""
	//code := 500
	//if strings.Contains(errToStr, "not set") {
	//	message = errToStr
	//} else {
	//	codeErr := CodeFromError(err)
	//	message = codeErr.Message()
	//	code = codeErr.Code()
	//}

	//errToStr := err.Error()
	//message := ""
	//codeErr := CodeFromError(err)
	//if codeErr.Code() == 500 {
	//	message = errToStr
	//} else {
	//	message = codeErr.Message()
	//}
	//return http.StatusOK, types.Status{
	//	Code:    int32(codeErr.Code()),
	//	Message: message,
	//}

	code := CodeFromError(err)
	return http.StatusOK, types.Status{
		Code:    int32(code.Code()),
		Message: code.Message(),
	}

}
